optionsFromStrings.js ➔ optionsFromStrings   B
last analyzed

Complexity

Conditions 5
Paths 8

Size

Total Lines 28

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 5
c 0
b 0
f 0
nc 8
nop 1
dl 0
loc 28
rs 8.439
1
export default optionsFromStrings;
2
3
// Convert string to integers/booleans where it should be
4
function optionsFromStrings(options){
5
	var intOptions = [
6
		"width",
7
		"height",
8
		"textMargin",
9
		"fontSize",
10
		"margin",
11
		"marginTop",
12
		"marginBottom",
13
		"marginLeft",
14
		"marginRight"
15
	];
16
17
	for(var intOption in intOptions){
18
		if(intOptions.hasOwnProperty(intOption)){
19
			intOption = intOptions[intOption];
20
			if(typeof options[intOption] === "string"){
21
				options[intOption] = parseInt(options[intOption], 10);
22
			}
23
		}
24
	}
25
26
	if(typeof options["displayValue"] === "string"){
27
		options["displayValue"] = (options["displayValue"] != "false");
28
	}
29
30
	return options;
31
}
32